package leetcode;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class XiaoHongShu {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        int[][] scores = new int[n][n];
        for (int i = 0; i < n; i++) {
            String[] s = br.readLine().split(" ");
            int[] ints = Arrays.stream(s).mapToInt(Integer::parseInt).toArray();
            scores[i] = ints;
        }
        int max = 0;
        for (int i = 0; i < n; i++) {
            int[] arr = new int[n];
            for (int j = i; j < n; j++) {
                for (int k = 0; k < n; k++) {
                    arr[k] +=scores[j][k];
                }
                // 数组和最大值
                max = Math.max(maxSum(arr,n),max);
            }
        }
        System.out.println(max);

    }
    public static int maxSum(int[] arr, int n) {
        int max = 0, sum = 0;
        for (int i = 0; i < n; i++) {
            if (sum <= 0) {
                sum = arr[i];
            }else {
                sum += arr[i];
            }
            max = Math.max(sum, max);
        }
        return max;
    }

    public void q3() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int[] s1 = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int n = s1[0];
        int k = s1[1];
        int[] s2 = Arrays.stream(br.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
        int j = 0;
        int[][] trees = new int[n][n];
        for (int i = 0; i < n; i++) {
            int[] arr = new int[n];
            int l = 0;
            while (l < 3) {
                arr[l++] = s2[j++];
                l++;
            }
            trees[i] = arr;
        }
        int[][] matrix = new int[n][n];
        // 邻接矩阵
        for (int i = 0; i < n; i++) {
            matrix[trees[i][0]][trees[i][1]] = trees[i][3];
            matrix[trees[i][1]][trees[i][0]] = trees[i][3];
        }
        int count = dfs(matrix, k);
        System.out.println(count);
    }

    public int dfs(int[][] matrix, int k) {
        int sum = 0;
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix.length; j++) {
                if (matrix[i][j] != 0 && matrix[i][j] < k) {
                    sum++;
                }
            }
        }
        return sum / 2;
    }
}
